package com.findFish.fish.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.findFish.common.annotation.Log;
import com.findFish.common.core.controller.BaseController;
import com.findFish.common.core.domain.AjaxResult;
import com.findFish.common.enums.BusinessType;
import com.findFish.fish.domain.FishHarvest;
import com.findFish.fish.service.IFishHarvestService;
import com.findFish.common.utils.poi.ExcelUtil;
import com.findFish.common.core.page.TableDataInfo;

/**
 * 鱼类收获记录Controller
 * 
 * @author admin
 * @date 2025-04-01
 */
@RestController
@RequestMapping("/fish/harvest")
public class FishHarvestController extends BaseController
{
    @Autowired
    private IFishHarvestService fishHarvestService;

    /**
     * 查询鱼类收获记录列表
     */
    @PreAuthorize("@ss.hasPermi('fish:harvest:list')")
    @GetMapping("/list")
    public TableDataInfo list(FishHarvest fishHarvest)
    {
        startPage();
        List<FishHarvest> list = fishHarvestService.selectFishHarvestList(fishHarvest);
        return getDataTable(list);
    }

    /**
     * 导出鱼类收获记录列表
     */
    @PreAuthorize("@ss.hasPermi('fish:harvest:export')")
    @Log(title = "鱼类收获记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FishHarvest fishHarvest)
    {
        List<FishHarvest> list = fishHarvestService.selectFishHarvestList(fishHarvest);
        ExcelUtil<FishHarvest> util = new ExcelUtil<FishHarvest>(FishHarvest.class);
        util.exportExcel(response, list, "鱼类收获记录数据");
    }

    /**
     * 获取鱼类收获记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('fish:harvest:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(fishHarvestService.selectFishHarvestById(id));
    }

    /**
     * 新增鱼类收获记录
     */
    @PreAuthorize("@ss.hasPermi('fish:harvest:add')")
    @Log(title = "鱼类收获记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FishHarvest fishHarvest)
    {
        return toAjax(fishHarvestService.insertFishHarvest(fishHarvest));
    }

    /**
     * 修改鱼类收获记录
     */
    @PreAuthorize("@ss.hasPermi('fish:harvest:edit')")
    @Log(title = "鱼类收获记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FishHarvest fishHarvest)
    {
        return toAjax(fishHarvestService.updateFishHarvest(fishHarvest));
    }

    /**
     * 删除鱼类收获记录
     */
    @PreAuthorize("@ss.hasPermi('fish:harvest:remove')")
    @Log(title = "鱼类收获记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(fishHarvestService.deleteFishHarvestByIds(ids));
    }
}
